"""
#my implmentation for jsonrpc-2.0 protocol

class Package(object):
    def from(method: str):
        return Package(method)

    def __init__(self, method: str, version: str="2.0"):
        self.method = method
        self.version = version

    def method(self):
        return self.method
    def version(self):
        return self.version

class Request(object):
    def __init__(self, method: str, params: list[object]):
        self.package = Package.from(method)
        self.params = params
    def params(self):
        return self.params

class Response(object):
    class Normal(object):
        pass
    class Error(object);
        pass
    def from_result():
        pass
    def from_error():
        pass

class Notify(INotify):
    pass


class JsonRpcCreator(object):
    def Request() -> IRequest
        pass
    def Response() -> IResponse:
        pass
    def ErrorResponse()->IResponse:
        pass
    def Notify() -> INotify:
        pass








#  server side code

TwoFactoryApplication().run()


class Server(object):
    def register(self)
        pass
    def unregister(self):
        pass
    def clear(self):
        pass
    def run(self):
        pass

class FlaskServer(Server):
    pass




class Application(object):
    def init(self):
        pass
    def deinit(self):
        pass
    
class ServerApplication(Application):
    def init(self):
        pass
    def deinit(self):
        pass
    def run(self):
        pass

class CommonServerApplication(ServerApplication):
    def __init__(self, server):
        self.__service = CommonService()
        self.__server = server

    def init(self):
        self.__server.register(self.__service.exit, name="common.exit")
        self.__server.register(self.__service.tick, name="common.tick")

    def deinit(self):
        self.__server.unregister(self.__service.exit)
        self.__server.unregister(self.__service.tick)
        self.__server = None
        self.__service = None

class CommonService(object):
    def exit(self):
        pass
    def tick(self):
        pass


class TwoFactoryApplication(CommonServerApplication):
    def __init__(self, server: Server):
        super().init(server)
        self.service = TwoFactorService(path, so_name)
        self.__server = server

    def init(self):
        super().init()

        #register the two_factor service
        self.__server.register(two_factor.sign, method="two_factor.sign")
        self.__server.register(two_factor.on_line, method="two_factor.on_line")

    def run(self):
        self.__server.run()

    def deinit(self):
        self.__server.unregister(two_factor.sign)
        self.__server.unregister(two_factor.on_line)
        self.__server = None
        self.__service = None

        super().deinit()


class TwoFactorService(object):
    def __init__(self, path:str, so_name: str):
        self.__two_factor = TwoFactorImpl(path, so_name)

    def sign(self) -> str:
        return self.cimpl().sign()
    def on_line(self) -> bool:
        return self.cimpl().online()

    def cimpl(self):
        return self.__two_factor
        

#C impl facade
class TwoFactorImpl(CImpl):
    def __init__(self, path, so_name):
        super().__init__(path, so_name)

    def sign(self) -> str:
        #prepare c-type input
        return self.target().sign()
        #handle c-type return

    def on_line(self) -> bool:
        #prepare c-type input
        return self.target().on_line()
        #handle c-type return

"""
